
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<head>
<title>Market place</title>
</head>

<body>
	<ui:composition>
		<p:panel id="shoppingCartPanel" styleClass="shoppingCartPanel"
			header="#{msgs.shoppingCart}" toggleable="true" style="width:100%">
			<p:dataTable border="" value="#{shoppingCartModel.basket}" sortBy="1" resizableColumns="true"
				paginatorAlwaysVisible="false" paginator="true"
				paginatorTemplate=" {PreviousPageLink} {PageLinks} {NextPageLink} "
				rows="12" emptyMessage="#{msgs.shoppingCartEmpty}" var="orderDetail"
				style="width:100%;padding:0px;left:0px;right:0px"
				rowClasses="oddRow, evenRow">
				<p:column>
					<h:graphicImage library="images"
						value="../#{orderDetail.product.icon}16.png"></h:graphicImage>
					<h:outputLabel value="#{orderDetail.product.nameLabel}"></h:outputLabel>
				</p:column>
				<p:column width="50">
					<p:spinner value="#{orderDetail.orderedQuantity}"   size="1" min="1">
						<p:ajax event="change" update=":rightForm,:headerForm"></p:ajax>
					</p:spinner>
				</p:column>
				<p:column width="12">
					<h:outputText value="#{orderDetail.product.stockUnitLabel}"></h:outputText>
				</p:column>

				<p:column width="18">
					<p:commandButton actionListener="#{shoppingCartModel.remove}"
						icon="delete" ajax="TRUE" update=":rightForm,:headerForm"
						immediate="true" style="width:20px;float:right;">
						<f:setPropertyActionListener target="#{shoppingCartModel.remove}"
							value="#{orderDetail.product}"></f:setPropertyActionListener>
					</p:commandButton>
				</p:column>
				<p:summaryRow>
					<p:column colspan="1">
						<h:outputText value="#{msgs.total}" style="float:right"></h:outputText>
					</p:column>
					<p:column colspan="3">
						<h:outputText id="inCartAmount"
							value="#{shoppingCartModel.order.orderedTotalAmount}"
							style="position:relative;float:right;font-weight:bold;text-align:right">
							<f:convertNumber type="currency" currencySymbol="$"
								minFractionDigits="2" maxFractionDigits="2" />
						</h:outputText>

					</p:column>
				</p:summaryRow>
			</p:dataTable>
			<h:panelGrid columns="2" style="width:100%">
				<p:commandLink value="#{msgs.emptyCart}"
					update=":rightForm,:headerForm" ajax="TRUE" immediate="true"
					actionListener="#{shoppingCartModel.emptyBasket}"
					style="float:left;margin-top:10px;margin-bottom:10px"></p:commandLink>

				<p:commandButton value="#{msgs.checkOut}" type="submit"
					disabled="#{shoppingCartModel.isBasketEmpty or shoppingCartModel.requiredDate.isPasted}"
					immediate="true" action="/user/checkOut.xhtml?faces-redirect=true"
					title="#{msgs.customer}:#{shoppingCartModel.customer.lastName} #{shoppingCartModel.customer.firstName} #{msgs.requiredDate}:#{shoppingCartModel.requiredDate.dateLabel}"
					style="float:right;background:green; color:white;margin-top:10px;margin-bottom:10px">
				</p:commandButton>
			</h:panelGrid>
			<ui:remove>
				<p:panel id="rushCustomerPanel"
					rendered="#{shoppingCartModel.requiredDate.canConfirm}">
					<h:outputFormat value="Your must check out in {0} minutes">
						<f:param value=""></f:param>
					</h:outputFormat>
					<p:poll interval="15" listener="#{counterBean.increment}"
						global="false" update="shoppingCartPanel" />
					<p:effect for="rushCustomerPanel" event="load" type="pulsate"
						speed="1000"></p:effect>
				</p:panel>
			</ui:remove>
		</p:panel>

	</ui:composition>
</body>

</html>


